package com.service;

import com.api.ItemService;
import com.dto.ItemDTO;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @author: sksun2
 * @create: 2023-02-10
 */
@Service
public class ItemServiceImpl implements ItemService {

    private Map<Long,ItemDTO> itemRepo = new HashMap<>();

    @PostConstruct
    public void init(){
        for(long i=1;i<=10;i++){
            ItemDTO itemDTO = new ItemDTO();
            itemDTO.setId(i);
            itemDTO.setName("商品:"+i);
            itemDTO.setDesc("商品详情:"+i);

            itemRepo.put(i,itemDTO);
        }
    }

    @Override
    public ItemDTO getItemById(Long id) {
        return itemRepo.get(id);
    }
}
